package reflect;

import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

public class ReflectDemo10 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        Class cls = Class.forName("reflect.Person");
        //获取sayHello方法
        Method method1 = cls.getMethod("sayHello");
        boolean mark1 = method1.isAnnotationPresent(AutoRunMethod.class);
        System.out.println("sayHello方法上是否有@AutoRunMethod:"+mark1);
        //获取sleep方法
        Method method2 = cls.getMethod("sleep");
        boolean mark2 = method2.isAnnotationPresent(AutoRunMethod.class);
        System.out.println("sleep方法上是否有@AutoRunMethod:"+mark2);
    }
}
